{{- $ := index . "$" -}}
{{- $Content := .raw -}}
{{- $isContent := .isContent -}}

<!-- New Syntax: Emphasis Point `..中文..` -->
<!-- https://www.w3.org/International/clreq/#id84 -->
{{- if $.Site.Params.enableEmphasisPoint -}}
    {{- $regexPatternEmphasisPoint := `\.\.([\p{Han}]+)\.\.` -}}
    {{- $regexReplacementEmphasisPoint := `<em class="emphasis-point">$1</em>` -}}
    {{- $Content = $Content | replaceRE $regexPatternEmphasisPoint $regexReplacementEmphasisPoint -}}
{{- end -}}

<!-- Markdownify -->
{{- if not $isContent -}}
    {{- $Content = $Content | markdownify -}}

    <!-- Emojify -->
    {{- if (fileExists "config.toml") -}}
        {{- $enableEmoji := replaceRE `enableEmoji = (.+)` `$1` (delimit (readFile "config.toml" | findRE `enableEmoji = (.+)` | uniq) " ") -}}
        {{- if eq $enableEmoji "true" -}}
            {{- $Content = $Content | emojify -}}
        {{- end -}}
    {{- end -}}
{{- end -}}

<!-- External Links -->
{{- if $.Site.Params.hrefTargetBlank -}}
    {{- $Content = replaceRE `(<a href="https?:[^"]+")` `$1 target="_blank" rel="noopener"` $Content -}}
{{- end -}}

{{- $Content | safeHTML -}}
